<template>
    <uni-transition custom-class="fade" :show="show">
      <div class="dialog" ref="dialog" v-if="show" @click="$emit('input', false)">
        <div class="dialog-content" :class="small ? 'small' : ''" @click.stop>
          <div class="title" v-if="title" style="flex: 1 0 auto;">{{title || $t('components.pub-dialog.497408-0')}}</div>
          <div class="content">
            <slot></slot>
          </div>
        </div>
      </div>
    </uni-transition>
  </template>
  
  <script>
  import protal from "@/api/protal";
  
  export default {
    name: "pub-dialog",
    props: {
      value: {
        type: Boolean,
        default: false,
      },
      small: {
        type: Boolean,
        default: false,
      },
      title:String
    },
    data() {
      return {
        show: false,
      };
    },
    watch: {
      value(v) {
        this.show = v;
        if (v) {
          this.$nextTick(() => {
            document.body.appendChild(this.$refs.dialog);
            document.body.style.overflow = "hidden";
          });
        } else {
          document.body.style.overflow = "auto";
        }
      },
    },
  };
  </script>
  
  <style lang="less" scoped>
  .dialog {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 6, 50, 0.4);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  
    .dialog-content {
      width: 800px;
      height: fit-content;
      background: #ffffff;
      border-radius: 12px;
      max-height: 80vh;
      display: flex;
      flex-direction: column;
  
      .title {
        width: 100%;
        height: 60px;
        background: linear-gradient(135deg, #1550ff 0%, #1777ff 100%);
        border-radius: 12px 12px 0px 0px;
        font-family: AlibabaPuHuiTi_3_85_Bold;
        font-size: 20px;
        color: #ffffff;
        line-height: 20px;
        text-align: justify;
        font-style: normal;
        display: flex;
        align-items: center;
        justify-content: center;
      }
  
      .content {
        flex: 1;
        overflow: auto;
        width: 100%;
  
        &::-webkit-scrollbar {
          width: 0;
        }
      }
    }
  }
  
  @media screen and (max-width: 750px) {
    .dialog {
      position: fixed;
      left: 0;
      top: 0;
      width: 100vw;
      height: 100vh;
      background: rgba(0, 6, 50, 0.4);
      z-index: 10;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
  
      .dialog-content {
        width: 5.8rem;
        height: fit-content;
        background: #ffffff;
        border-radius: .12rem;
        max-height: 80vh;
        display: flex;
        flex-direction: column;
  
        &.small {
          width: 6.7rem;
        }
  
        .title {
          width: 100%;
          height: .96rem;
          background: linear-gradient(135deg, #1550ff 0%, #1777ff 100%);
          border-radius: .12rem .12rem 0px 0px;
          font-family: AlibabaPuHuiTi_3_85_Bold;
          font-size: .36rem;
          color: #ffffff;
          line-height: 1;
          text-align: justify;
          font-style: normal;
          display: flex;
          align-items: center;
          justify-content: center;
        }
  
        .content {
          flex: 1;
          width: 100%;
          padding-bottom: 0;
          overflow: visible;
  
          &::-webkit-scrollbar {
            width: 0;
          }
        }
      }
    }
  
  }
  
  </style>
  